package com.dhcc.DRGsHosp.facade.impl.assembler;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import com.dhcc.DRGsHosp.core.domain.Order;
import com.dhcc.DRGsHosp.facade.dto.OrderDTO;

public class OrderAssembler {
	
	public static OrderDTO  toDTO(Order  order){
		if (order == null) {
			return null;
		}
		OrderDTO orderDto  = new OrderDTO();
		orderDto.setAdrgCode(order.getAdrgCode());
		orderDto.setDateFrom(order.getDateFrom());
		orderDto.setDateTo(order.getDateTo());
		orderDto.setDepCode(order.getDepCode());
		orderDto.setDepGroupCode(order.getDepGroupCode());
		orderDto.setDrgCode(order.getDrgCode());
		orderDto.setIsExceeding(order.getIsExceeding());
		orderDto.setIsHighOrder(order.getIsHighOrder());
		orderDto.setIsPrimaryFee(order.getIsPrimaryFee());
		orderDto.setIsPrimaryUse(order.getIsPrimaryUse());
		orderDto.setManageYear(order.getManageYear());
		orderDto.setNotExceedingOrders(order.getNotExceedingOrders());
		orderDto.setOrderDesc(order.getOrderDesc());
		orderDto.setOrderDocDep(order.getOrderDocDep());
		orderDto.setOrderDocDepCode(order.getOrderDocDepCode());
		orderDto.setOrderDoctor(order.getOrderDoctor());
		orderDto.setOrderFirstpageFee(order.getOrderFirstpageFee());
		orderDto.setOrderId(order.getOrderId());
		orderDto.setOrderMrId(order.getOrderMrId());
		orderDto.setOrderQuantity(order.getOrderQuantity());
		orderDto.setOrderReceiveDep(order.getOrderReceiveDep());
		orderDto.setOrderReceiveDepCode(order.getOrderReceiveDepCode());
		orderDto.setOrderSubcate(order.getOrderSubcate());
		orderDto.setOrderTotalFee(order.getOrderTotalFee());
		orderDto.setOrderUnitPrice(order.getOrderUnitPrice());
		orderDto.setpType(order.getpType());
		orderDto.setStdId(order.getStdId());
		orderDto.setClinicGroup(order.getClinicGroup());
		orderDto.setOrderFirstpageFeeDesc(order.getOrderFirstpageFeeDesc());
		orderDto.setOrderSubcateDesc(order.getOrderSubcateDesc());
     	return orderDto;
	 }
	
	public static List<OrderDTO>  toDTOs(Collection<Order>  Orders){
		if (Orders == null) {
			return null;
		}
		List<OrderDTO> orderDtos = new ArrayList<OrderDTO>();
		for (Order each : Orders) {
			orderDtos.add(toDTO(each));
		}
		return orderDtos;
	}
	
	 public static Order  toEntity(OrderDTO  orderDto){
			if (orderDto == null) {
				return null;
			}
			Order order  = new Order();
			order.setAdrgCode(orderDto.getAdrgCode());
			order.setDateFrom(orderDto.getDateFrom());
			order.setDateTo(orderDto.getDateTo());
			order.setDepCode(orderDto.getDepCode());
			order.setDepGroupCode(orderDto.getDepGroupCode());
			order.setDrgCode(orderDto.getDrgCode());
			order.setIsExceeding(orderDto.getIsExceeding());
			order.setIsHighOrder(orderDto.getIsHighOrder());
			order.setIsPrimaryFee(orderDto.getIsPrimaryFee());
			order.setIsPrimaryUse(orderDto.getIsPrimaryUse());
			order.setManageYear(orderDto.getManageYear());
			order.setNotExceedingOrders(orderDto.getNotExceedingOrders());
			order.setOrderDesc(orderDto.getOrderDesc());
			order.setOrderDocDep(orderDto.getOrderDocDep());
			order.setOrderDocDepCode(orderDto.getOrderDocDepCode());
			order.setOrderDoctor(orderDto.getOrderDoctor());
			order.setOrderFirstpageFee(orderDto.getOrderFirstpageFee());
			order.setOrderId(orderDto.getOrderId());
			order.setOrderMrId(orderDto.getOrderMrId());
			order.setOrderQuantity(orderDto.getOrderQuantity());
			order.setOrderReceiveDep(orderDto.getOrderReceiveDep());
			order.setOrderReceiveDepCode(orderDto.getOrderReceiveDepCode());
			order.setOrderSubcate(orderDto.getOrderSubcate());
			order.setOrderTotalFee(orderDto.getOrderTotalFee());
			order.setOrderUnitPrice(orderDto.getOrderUnitPrice());
			order.setpType(orderDto.getpType());
			order.setStdId(orderDto.getStdId());
			order.setClinicGroup(orderDto.getClinicGroup());
			order.setOrderFirstpageFeeDesc(orderDto.getOrderFirstpageFeeDesc());
			order.setOrderSubcateDesc(orderDto.getOrderSubcateDesc());
	     	return order;
		 }
	
	public static List<Order> toEntities(Collection<OrderDTO> orderDtos) {
		if (orderDtos == null) {
			return null;
		}
		
		List<Order> order = new ArrayList<Order>();
		for (OrderDTO each : orderDtos) {
			order.add(toEntity(each));
		}
		return order;
	}
}
